package com.czf.testmodule.io.bio;

import lombok.extern.slf4j.Slf4j;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author zfChen
 * @create 2022/6/13 14:38
 */
@Slf4j
public class Server {
    public static void main(String[] args) {
        log.info("===服务端启动===");
        try {
            ServerSocket socket = new ServerSocket(9999);
            Socket accept = socket.accept();
            InputStream inputStream = accept.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            String msg;
            while ((msg = bufferedReader.readLine()) != null){
                System.out.println("服务端接收到：" + msg);
            }
        log.info("===服务端结束===");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
